package edu.pku.sei.modeler.actions.registry;

import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionGroup;

import edu.pku.sei.modeler.model.structure.MetaDiagram;

public abstract class EditorActionGroup extends ActionGroup {
	private EditPartViewer viewer;
	public EditPartViewer getViewer() {
		return viewer;
	}

	private MetaDiagram diagram;
	public MetaDiagram getDiagram() {
		return diagram;
	}

	private ActionRegistry defaultActions;
	public ActionRegistry getDefaultActions() {
		return defaultActions;
	}

	public EditorActionGroup(EditPartViewer viewer, ActionRegistry defaultActions, MetaDiagram diagram) {
		this.viewer = viewer;
		this.diagram = diagram;
		this.defaultActions = defaultActions;
	}
	
	@Override
	public abstract void fillContextMenu(IMenuManager menu);
	
	protected void fillDefaultActions(IMenuManager menu) {
		menu.add(new Separator(GEFActionConstants.GROUP_UNDO));
		menu.add(new Separator(GEFActionConstants.GROUP_COPY));
		menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
	
		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, defaultActions.getAction(ActionFactory.UNDO.getId()));
		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, defaultActions.getAction(ActionFactory.REDO.getId()));
		menu.appendToGroup(GEFActionConstants.GROUP_COPY, defaultActions.getAction(ActionFactory.COPY.getId()));
		menu.appendToGroup(GEFActionConstants.GROUP_COPY, defaultActions.getAction(ActionFactory.CUT.getId()));
		menu.appendToGroup(GEFActionConstants.GROUP_COPY, defaultActions.getAction(ActionFactory.PASTE.getId()));
		menu.appendToGroup(GEFActionConstants.GROUP_EDIT, defaultActions.getAction(ActionFactory.DELETE.getId()));
	}
}
